package com.glorysoft.knowlespda.utils;

import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import com.pda.platform.ui.ui_pdaplatform.R.id;
import com.pda.platform.ui.ui_pdaplatform.R.layout;
import com.pda.platform.ui.ui_pdaplatform.callback.FreeUI_CommonCallback;
import com.pda.platform.ui.ui_pdaplatform.callback.FreeUI_TextCallback;
import com.pda.platform.ui.ui_pdaplatform.dialog.FreeUI_GeneralFragmentDialog;
import com.pda.platform.ui.ui_pdaplatform.view.FreeUI_ClearEditText;

public class FreeApi_DialogUtils {
    public FreeApi_DialogUtils() {
    }

    public static FreeUI_GeneralFragmentDialog getFreeDialog(View contentView) {
        FreeUI_GeneralFragmentDialog freeUI_generalFragmentDialog = new FreeUI_GeneralFragmentDialog();
        freeUI_generalFragmentDialog.setLayout(contentView);
        return freeUI_generalFragmentDialog;
    }

    public static FreeUI_GeneralFragmentDialog getConfirmDialog(Context context, String confirm, String tips, String title, final FreeUI_CommonCallback confirmCallback) {
        final FreeUI_GeneralFragmentDialog freeUI_generalFragmentDialog = new FreeUI_GeneralFragmentDialog();
        View contentView = LayoutInflater.from(context).inflate(layout.free_ui_dark_dialog_with_confirm_and_cancel, (ViewGroup)null);
        TextView tvCancel = (TextView)contentView.findViewById(id.tvCancel);
        TextView tvConfirm = (TextView)contentView.findViewById(id.tvConfirm);
        TextView tvTips = (TextView)contentView.findViewById(id.tvTips);
        TextView tvTitle = (TextView)contentView.findViewById(id.tvTitle);
        tvTips.setText(tips);
        tvTitle.setText(title);
        tvCancel.setVisibility(View.GONE);
        tvConfirm.setText(confirm);
        tvConfirm.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                confirmCallback.onSuccess();
                freeUI_generalFragmentDialog.dismiss();
            }
        });
        freeUI_generalFragmentDialog.setLayout(contentView);
        return freeUI_generalFragmentDialog;
    }

}
